package com.zhr.tea.view.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.zhr.tea.R;
import com.zhr.tea.entity.shouye.BodyCentent;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ym on 2016/11/1.
 */

public class ShouyeXianshiAdapter extends RecyclerView.Adapter<ShouyeXianshiAdapter.MyViewHolder> {

    private List<BodyCentent.ContentBean.BenefitSaleBean.GoodsListBean> data;
    private Context context;

    public ShouyeXianshiAdapter(Context context, List<BodyCentent.ContentBean.BenefitSaleBean.GoodsListBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_shouye_type3_recycle, null);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        Glide.with(context).load(data.get(position).getTitlePhoto()).placeholder(R.mipmap.ic_launcher).into(holder.ivXianshi);
        holder.tvBaokuan.setText(data.get(position).getTag());
        holder.tvTitle.setText(data.get(position).getSecondSalePhoto());
        holder.tvPrice.setText("¥"+data.get(position).getPrice());
        holder.tvOldprice.setText("¥"+data.get(position).getMarketPrice());
        holder.tvOldprice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_xianshi)
        ImageView ivXianshi;
        @BindView(R.id.tv_baokuan)
        TextView tvBaokuan;
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_price)
        TextView tvPrice;
        @BindView(R.id.tv_oldprice)
        TextView tvOldprice;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
